package com.me.prototype.deepclone;

import lombok.SneakyThrows;

public class Client {
    @SneakyThrows
    public static void main(String[] args) {
        // --------------------------------------- 深拷贝 ----------------------------------
        DeepProtoType p = new DeepProtoType();
        p.name = "宋江";
        p.deepCloneableTarget = new DeepCloneableTarget("大牛", "小牛");

        // 深拷贝-方式1
        DeepProtoType p1 = (DeepProtoType) p.clone();
        System.out.println("p.name="+p.name+",p.deepCloneableTarget=" + p.deepCloneableTarget.hashCode());
        System.out.println("p1.name="+p1.name+",p1.deepCloneableTarget=" + p1.deepCloneableTarget.hashCode());

        // 深拷贝-方式2
        DeepProtoType p2 = (DeepProtoType) p.deepClone();
        System.out.println("p.name="+p.name+",p.deepCloneableTarget=" + p.deepCloneableTarget.hashCode());
        System.out.println("p2.name="+p2.name+",p2.deepCloneableTarget=" + p2.deepCloneableTarget.hashCode());

    }
}
